<template>

    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
                <router-link :to="'/home/newslist/newsinfo/'+item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <h1>{{ item.title }}</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间：<span>{{ item.add_time }}</span></span>
                            <span>点击 <span>{{ item.click }}</span> 次</span>
                        </p>
                    </div>
                </router-link>
            </li>
            <li class="mui-table-view-cell mui-media">
                <a href="javascript:;">
                    <img class="mui-media-object mui-pull-left" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2716771220,1785419968&fm=26&gp=0.jpg">
                    <div class="mui-media-body">
                        <h1>烤炉模式的城，到黄昏，如同打翻的调色盘一般.</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间：<span>2020-07-20 00:05</span></span>
                            <span>点击 <span>100+</span> 次</span>
                        </p>
                    </div>
                </a>
            </li>
        
            <li class="mui-table-view-cell mui-media">
                <a href="javascript:;">
                    <img class="mui-media-object mui-pull-left" src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1360415135,1923461153&fm=26&gp=0.jpg">
                    <div class="mui-media-body">
                        <h1>调用 dateFormat、moment 格式化时间</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间：<span>{{ date | dateFormat }}</span></span>
                            <span>点击 <span>999+</span> 次</span>
                        </p>
                    </div>
                </a>
            </li>
        </ul>
    </div>
</template>

<script>
    export default {
        name: 'NewList',
        data() {
            return {
				newslist: [],
				date: new Date()
            }
        },
        methods: {
            getNews(){
                let url = "https://www.fastmock.site/mock/3bcb60e708abec194c722ac5464b28d8/VueApp/getnewslist"
                this.$http.get(url).then(result=>{
                    if(result.status == 200){ // 请求成功
                        this.newslist = result.data.message
                    } else{
                        // consolel.log(this)
                    }
                })
            }
        },
        created() {
			// console.log(this.date)
            this.getNews()
        },
    }
</script>

<style lang="scss" scoped>
    .mui-table-view{
        // background-color:yellow;
        li{
            
            h1{
                font-size: 14px;
                font-weight: bold;
                color: crimson;
                /* 设置文字过长时 省略号代替 */
                display: block;
                width: 80%;
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;
            }
            .mui-ellipsis{
                display: flex;
                justify-content: space-between;
                span{
                    font-size: 12px;
                    color: silver;
					&:nth-child(1)>span{
						color: darkcyan;
					}
					&:nth-child(2)>span{
						color: crimson;
						font-weight: bold;
					}
                }
            }
        }
    }
</style>